#include <iostream>
#include <string>
#include <vector>
using namespace std;

int main(){

    string s;
    cin >> s;
    int n = s.size();
    vector<vector<int>> dp(n + 10, vector<int>(n + 10, 0));
    // 开始填表
    for (int i = n; i >= 1; i--){
        for (int j = 1; j <= n; j++){
            if (i == j) dp[i][j] = 1;
            else if (i > j) dp[i][j] = 0;
            else {
                if (s[i] == s[j]) dp[i][j] = dp[i + 1][j - 1] + 2;
                else dp[i][j] = max(dp[i][j - 1], dp[i + 1][j]);
            }
        }
    }

    cout << dp[1][n] << endl;
    return 0;
}